<template>
	<view class="content">

		<u-navbar title="工作台">
			<view class="u-nav-slot" slot="left">
				<view class="NavbarLeft">
					<!-- 回退按钮 -->
					<u-icon name="arrow-left" color="#fff" :duration="0" size="20" @click="GoBack"></u-icon>
				</view>
			</view>
		</u-navbar>

		<view style="margin-top: 50px;padding: 20rpx 20rpx;">
			<uni-row class="CommonBox" :gutter="20">
				<uni-col v-for="(item,index) in NvoicesList" :key="index" :span="8" :xs="{span: 8}" :sm="{span: 4}"
					:lg="{span: 3}">
					<view class="CommonCard" @click="ChoiceNovices(item)">
						<!-- <uni-icons :color="item.Color" custom-prefix="iconfont" :type="item.IconImg"
							size="40"></uni-icons> -->
						<uni-icons fontFamily="CustomFontPlatform" :color="item.AP_Colour"
							:size="40">{{$utils.toUniCode(item.PIC_PH)}}</uni-icons>

						<view style="text-align: center;margin-top: 10px;font-size: 20rpx;">
							<text>{{item.APFunName}}</text>
						</view>
					</view>
				</uni-col>
			</uni-row>

		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				IsDemo: false, // 是否是演示账套
				NvoicesList: [], // 可新增单据列表 -- 数据维护在 vuex
			}
		},
		onLoad() {
			var that = this
			that.IsDemo = uni.getStorageSync('App_demo') || false;

		},
		onShow() {
			var that = this
			// 从vuex中获取检验类型数据
			//that.NvoicesList = that.$store.state.appConfigInfo.ModuleInfo_All[0]['Node'].filter(item => !item.IsTabbar);

			let organizedData = this.$store.state.appConfigInfo.ModuleInfo_All.filter(item => !item.IsTabbar);
			console.log(organizedData);
			that.NvoicesList = organizedData.flatMap(item => item.Node.filter(row => !row.IsTabbar))
				.sort((a, b) => a.APFunCode - b.APFunCode); // 对结果进行排序
			// 强制横屏
			plus.screen.lockOrientation('portrait-primary');
			// 清一下缓存
			uni.removeStorageSync('OrderUrl');
			uni.removeStorageSync('OrderID');


		},
		beforeDestroy() {
			// plus.screen.lockOrientation('portrait-primary');
			this.NvoicesList = null;
		},
		methods: {
			ChoiceNovices(data) { // 选中新增单据类型
				// uni.navigateTo({
				// 	url: "/st_qms/LabReport/experimentResult"
				// })
				// return
				// console.log(data);
				uni.setStorageSync('OrderID', data.APPFunID);
				if (data.AP_Link.includes('.html')) {
					let url = ''

					uni.hideToast();
					plus.screen.lockOrientation('landscape-primary');

					setTimeout(() => {
						uni.navigateTo({ // 前往表单界面 lucksheet
							url: '/st_qms/index/DocumentPage'
						});
					}, 300)
				} else {
					uni.hideToast();

					setTimeout(() => {
						uni.navigateTo({
							url: data.AP_Link
						});
					}, 300)
				}

			},
			GoBack() {
				var pages = getCurrentPages();
				setTimeout(() => {
					uni.navigateBack();
				}, 300)
			}
		}
	}
</script>

<style lang="scss">
	* {
		padding: 0;
		margin: 0;
		box-sizing: border-box;
	}


	.content {
		/* 给顶部盒子安全高度 */
		padding-top: var(--status-bar-height);
	}

	.CommonCard {
		background-color: #f6f6f6;
		border-radius: 12px;
		display: flex;
		flex-direction: column;
		justify-content: center;
		padding: 15px 0;
		margin-bottom: 20px;
		box-shadow: 1px 1px 7px -6px #bababa;
		position: relative;

		&:active {
			transform: scale(0.98);
			box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
		}

		&::after {
			content: '';
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			bottom: 0;
			background: rgba(81, 208, 208, 0.05);
			opacity: 0;
			transition: opacity 0.3s;
		}

		&:active::after {
			opacity: 1;
			border-radius: 12px;
		}
	}
</style>